<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% if user %}编辑用户{% else %}添加用户{% endif %}</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
        }
        .container {
            max-width: 600px;
            margin: 0 auto;
            padding: 20px;
        }
        h1 {
            color: #333;
        }
        .form-group {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        input[type="text"],
        input[type="password"] {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        .btn {
            padding: 8px 15px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>{% if user %}编辑用户{% else %}添加用户{% endif %}</h1>
        <form method = "post" action="{% if user %}{{ url_for('edit_user', id=user.userid) }}{% else %}{{ url_for('add_user') }}{% endif %}">
            <div class="form-group">
                <label for="username">用户名:</label>
                <input type="text" id="username" name="username" required value="{% if user %}{{ user.username }}{% endif %}">
            </div>
            <div class="form-group">
                <label for="password">密码:</label>
                <input type="password" id="password" name="password" required value="{% if user %}{{ user.password }}{% endif %}">
            </div>
            <div class="form-group">
                <label for="role">角色:</label>
                <select required name="role">
                {% if user %}
                <option value="{{ user.role }}">{% if user.role=="user" %}普通用户{% else %}管理员{% endif %}	</option>
                <option value="{% if user.role=='user' %}admin{% else %}user{% endif %}">{% if user.role=="user" %}管理员{% else %}普通用户{% endif %}	</option>
                {% else %}
                
					
					<option value="user">普通用户</option>
					<option value="admin">管理员</option>
				{% endif %}	
				</select>
                
            </div>
            <button type="submit" class="btn">{% if user %}更新用户{% else %}添加用户{% endif %}</button>
        </form>
    </div>
</body>
</html>